package com.example.shop.common.bo.sms.template;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Data
public class CodeTemplateParam implements SMSTemplateGenerator{
    //登录授权码
    private String code;
    public CodeTemplateParam(String code){
        this.code = code;
    }
    @Override
    public String generateTemplateParam() {
        ObjectMapper objectMapper = new ObjectMapper();
        String json = null;
        try {
            json = objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            System.out.println("LoginCodeTemplateParam转换成json错误");
        }
        return json;
    }
}
